<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="com.springboot.dto.WebDoctorViewPatient" %>
<%@ page import="java.util.ArrayList" %>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>近期预约</title>
    <link rel="stylesheet" href="../assets/css/iconfont.css">
    <link rel="stylesheet" href="../assets/css/layui.css">
    <link rel="stylesheet" href="../assets/css/view.css"/>
    <link rel="stylesheet" href="../assets/css/admin.css"/>
    <link rel="stylesheet" href="../assets/css/style.css"/>
</head>
<body class="layui-view-body">
<div class="layui-content">
    <!--面包屑导航-->
    <div class="mianb">
        <div class="mblf layui-col-xs6 layui-col-md6">
            <i class="layui-icon">&#xe656;</i>
            <p>查看预约 > <span>近期预约</span></p>
        </div>
<%--        <div class="mbrt layui-col-xs6 layui-col-md6">--%>
<%--            <a href="javascript:;" class="layui-btn layui-btn-normal" id="fabu">一键导出</a>--%>
<%--        </div>--%>
    </div>
    <!--面包屑导航-->
    <div class="layui-row">
        <div class="layui-card">
            <div class="table-responsive" id="dq">
                <table class="layui-table" lay-skin="line" lay-size="lg" id="table">
                    <thead>
                    <tr>
                        <th class="layui-form">
                            <input type="checkbox" name="" lay-skin="primary" title="">
                        </th>
                        <th>序号</th>
                        <th>患者姓名</th>
                        <th>患者手机号</th>
                        <th>预约日期</th>
                        <th>预约时间</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <%
                        ArrayList<WebDoctorViewPatient> doctorViewPatients = new ArrayList<>();
                        doctorViewPatients = (ArrayList<WebDoctorViewPatient>)session.getAttribute("doctorViewPatients2");
                        if(doctorViewPatients==null)
                        {
                           doctorViewPatients = new ArrayList<WebDoctorViewPatient>();
                        }
                        else {

                        }
                        for(int i=0;i<doctorViewPatients.size();i++)
                        {
                            WebDoctorViewPatient doctorViewPatient = doctorViewPatients.get(i);

                    %>
                    <tr>
                        <td></td>
                        <td><%= i+1 %></td>
                        <td><%= doctorViewPatient.getPatientName() %></td>
                        <td><%= doctorViewPatient.getPatientTel() %></td>
                        <td><%= doctorViewPatient.getOrderDate() %></td>
                        <td><%= doctorViewPatient.getOrderTime() %></td>
                        <td>
                            <div class="layui-table-cell laytable-cell-1-0-10">
                                <button class="layui-btn layui-btn-normal cancel" id="<%= doctorViewPatient.getBookId() %>">取消预约</button>
                            </div>
                        </td>
                    </tr>
                    <%
                        }
                    %>
                    </tbody>
                </table>
            </div>

            <!--分页-->
            <div id="page"></div>
            <!--分页-->
        </div>
    </div>
</div>
<script src="../assets/jquery.min.js"></script>
<script src="../assets/layui.all.js"></script>
<script>
    window.onload = function () {
        //进入页面获取医生今日预约
        $.ajax({
            url:"http://localhost:8080/webgetPatientServlet",
            type:"post",
            data:{},
            dataType:"text",
            success:function(data){
                $("#dq").load(location.href+" #dq>*","");

            },
            error:function(data){
                alert("Error");
            }
        });


        $("#dq").on('click', "button", function () {
            var btnid =  $(this).attr("id");
            var r = confirm("您确定要取消预约吗？请重复确认");
            if (r == true) {
                $.ajax({
                    url:"http://localhost:8080/webdoctorCancelAppoint",
                    type:"post",
                    data:{bookId:btnid},
                    dataType:"text",
                    success:function(data){
                        location.reload();
                    },
                    error:function(data){
                        alert("Error");
                    }
                });
            }
        });

    }

/*
    var element = layui.element;
    layui.use(['laypage', 'layer'], function(){
        var laypage = layui.laypage
            ,layer = layui.layer;
        //页码完整功能
        laypage.render({
            elem: 'page'
            ,count: 100
            ,layout: ['count', 'prev', 'page', 'next', 'limit', 'skip']
            ,jump: function(obj){
                console.log(obj)
            }
        });
    });

    //弹框
    $('#fabu').on('click', function(){
        layui.use('layer', function(){
            var layer = layui.layer;
            layer.open({
                type: 2,
                title: '发布任务',
                fix: false,
                shadeClose: true,
                shade: 0.8,
                area: ['660px', '420px'],
                content: '02任务发布-发布任务.html',
                end: function () {
                    location.reload();
                }
            });
        });
    })

    //判断弹框
    $(".delete").click(function(){
        layer.confirm('确定要删除此任务？', {
            btn: ['是','否'] //按钮
        }, function(){
            layer.msg('已删除', {icon: 1});
        }, function(){
            layer.msg('已取消',  {icon: 2});
        });
    })

    layui.use('form', function(){
        var form = layui.form;
        form.render();
    });*/
</script>
</body>
</html>
